package com.mathdemo;

public class MathTest2 {
    public static void main(String[] args) {
        //要求1:统计一共有多少个水仙花数。
        int count1=0;
        //水仙花数100~999
        for (int i = 100; i <= 999; i++) {
            int temp=i;
            double sum=0;
            while (temp!=0){
                sum+=Math.pow(temp%10,3);
                temp=temp/10;
            }
            if(sum==i){
                System.out.println(i);
                count1++;
            }
        }
        System.out.println(count1);
        System.out.println("=========");


        //要求2:判断一下为什么没有两位自幂数。
        int count2=0;
        //两位数10~99
        for (int i = 10; i <= 99; i++) {
            int temp=i;
            double sum=0;
            while (temp!=0){
                sum+=Math.pow(temp%10,2);
                temp=temp/10;
            }
            if(sum==i){
                System.out.println(i);
                count2++;
            }
        }
        System.out.println(count2);
        System.out.println("=========");

        //要求3:统计一共有多少个四叶玫瑰数,五角星数
        //四叶玫瑰数
        int count3=0;
        for (int i = 1000; i <= 9999; i++) {
            int temp=i;
            double sum=0;
            while (temp!=0){
                sum+=Math.pow(temp%10,4);
                temp=temp/10;
            }
            if(sum==i){
                System.out.println(i);
                count3++;
            }
        }
        System.out.println(count3);
        System.out.println("=========");
        //五角星数
        int count4=0;
        for (int i = 10000; i <= 99999; i++) {
            int temp=i;
            double sum=0;
            while (temp!=0){
                sum+=Math.pow(temp%10,5);
                temp=temp/10;
            }
            if(sum==i){
                System.out.println(i);
                count4++;
            }
        }
        System.out.println(count4);
        System.out.println("=========");
    }

}
